﻿@{
    Layout = null;
}

@if (Convert.ToBoolean(ViewData["IsModal"]))
{
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="uploadModalLabel">Modal title</h4>
            </div>
            <div class="modal-body" id="uploadModalBody">
                <link href="~/Content/FileUpload/css/bootstrap/bootstrap-image-gallery.debug.css" rel="stylesheet" />
                <link href="~/Content/FileUpload/css/jquery.fileupload-ui.css" rel="stylesheet" />
                <div>
                    <!-- The file upload form used as target for the file upload widget -->
                    <form id="fileupload" action="/Backload/UploadHandler" method="POST" enctype="multipart/form-data">
                        <!-- Redirect browsers with JavaScript disabled to the origin page -->
                        <noscript>
                            <input type="hidden" name="redirect" value="/"></noscript>
                        <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
                        <div class="row fileupload-buttonbar">
                            <div class="col-lg-7">
                                <!-- The fileinput-button span is used to style the file input field as button -->
                                <span class="btn btn-success fileinput-button">
                                    <i class="icon-plus icon-white"></i>
                                    <span>Add files...</span>
                                    <input type="file" name="files[]" multiple>
                                </span>
                                <button type="submit" class="btn btn-primary start">
                                    <i class="icon-upload icon-white"></i>
                                    <span>Start upload</span>
                                </button>
                                <button type="reset" class="btn btn-warning cancel">
                                    <i class="icon-ban-circle icon-white"></i>
                                    <span>Cancel upload</span>
                                </button>
                                <button type="button" class="btn btn-danger delete">
                                    <i class="icon-trash icon-white"></i>
                                    <span>Delete</span>
                                </button>
                                <input type="checkbox" class="toggle">
                                <!-- The loading indicator is shown during file processing -->
                                <span class="fileupload-loading"></span>
                            </div>
                            <!-- The global progress information -->
                            <div class="col-lg-5 fileupload-progress fade">
                                <!-- The global progress bar -->
                                <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                                    <div class="bar" style="width: 0%;"></div>
                                </div>
                                <!-- The extended global progress information -->
                                <div class="progress-extended">&nbsp;</div>
                            </div>
                        </div>
                        <hr />
                        <!-- The table listing the files available for upload/download -->
                        <table role="presentation" class="table table-striped">
                            <tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody>
                        </table>
                    </form>

                    <!-- The template to display files available for upload -->
                    <script id="template-upload" type="text/x-tmpl">
                    {% for (var i=0, file; file=o.files[i]; i++) { %}
                        <tr class="template-upload fade">
                            <td>
                                <span class="preview"></span>
                            </td>
                            <td>
                                <p class="name">{%=file.name%}</p>
                                {% if (file.error) { %}
                                    <div><span class="label label-important">Error</span> {%=file.error%}</div>
                                {% } %}
                            </td>
                            <td>
                                <p class="size">{%=o.formatFileSize(file.size)%}</p>
                                {% if (!o.files.error) { %}
                                    <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
                                {% } %}
                            </td>
                            <td>
                                {% if (!o.files.error && !i && !o.options.autoUpload) { %}
                                    <button class="btn btn-primary start">
                                        <i class="icon-upload icon-white"></i>
                                        <span>Start</span>
                                    </button>
                                {% } %}
                                {% if (!i) { %}
                                    <button class="btn btn-warning cancel">
                                        <i class="icon-ban-circle icon-white"></i>
                                        <span>Cancel</span>
                                    </button>
                                {% } %}
                            </td>
                        </tr>
                    {% } %}
                    </script>
                    <!-- The template to display files available for download -->
                    <script id="template-download" type="text/x-tmpl">
                    {% for (var i=0, file; file=o.files[i]; i++) { %}
                        <tr class="template-download fade">
                            <td>
                                <span class="preview">
                                    {% if (file.thumbnail_url) { %}
                                        <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
                                    {% } %}
                                </span>
                            </td>
                            <td>
                                <p class="name">
                                    <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
                                </p>
                                {% if (file.error) { %}
                                    <div><span class="label label-important">Error</span> {%=file.error%}</div>
                                {% } %}
                            </td>
                            <td>
                                <span class="size">{%=o.formatFileSize(file.size)%}</span>
                            </td>
                            <td>
                                <button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                                    <i class="icon-trash icon-white"></i>
                                    <span>Delete</span>
                                </button>
                                <input type="checkbox" name="delete" value="1" class="toggle">
                            </td>
                        </tr>
                    {% } %}
                    </script>
                </div>
                <input id="ServerDocumentId" type="hidden" value="@ViewData["DocumentId"]" />
                <script src="~/Scripts/jquery-2.1.0.min.js"></script>
                <script src="~/Scripts/jquery-ui-1.10.4.min.js"></script>

                <!-- We use Backloads. bundeling feature to register only those client side javascript and style files of the jQuery File Upload Plugin that are needed  -->
                <script src="~/Scripts/FileUpload/jqueryui/jquery.ui.widget.js"></script>
                <script src="~/Scripts/FileUpload/tmpl.debug.js"></script>
                <script src="~/Scripts/FileUpload/load-image.debug.js"></script>
                <script src="~/Scripts/FileUpload/canvas-to-blob.debug.js"></script>
                <script src="~/Scripts/FileUpload/bootstrap/bootstrap.debug.js"></script>
                <script src="~/Scripts/FileUpload/bootstrap/bootstrap-image-gallery.debug.js"></script>
                <script src="~/Scripts/FileUpload/jquery.iframe-transport.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload-process.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload-image.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload-audio.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload-video.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload-validate.js"></script>
                <script src="~/Scripts/FileUpload/jquery.fileupload-ui.js"></script>

                <!-- Initialize the jQuery File Upload Plugin -->
                <script src="~/Scripts/FileUpload/backload.demo.js"></script>
            </div>
            <div id="uploadModalFooter" class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Đóng lại</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
}
else
{
    <link href="~/Content/FileUpload/css/bootstrap/bootstrap-image-gallery.debug.css" rel="stylesheet" />
    <link href="~/Content/FileUpload/css/jquery.fileupload-ui.css" rel="stylesheet" />
    <div>
        <!-- The file upload form used as target for the file upload widget -->
        <form id="fileupload" action="/Backload/UploadHandler" method="POST" enctype="multipart/form-data">
            <!-- Redirect browsers with JavaScript disabled to the origin page -->
            <noscript>
                <input type="hidden" name="redirect" value="/"></noscript>
            <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
            <div class="row fileupload-buttonbar">
                <div class="col-lg-7">
                    <!-- The fileinput-button span is used to style the file input field as button -->
                    <span class="btn btn-success fileinput-button">
                        <i class="icon-plus icon-white"></i>
                        <span>Add files...</span>
                        <input type="file" name="files[]" multiple>
                    </span>
                    <button type="submit" class="btn btn-primary start">
                        <i class="icon-upload icon-white"></i>
                        <span>Start upload</span>
                    </button>
                    <button type="reset" class="btn btn-warning cancel">
                        <i class="icon-ban-circle icon-white"></i>
                        <span>Cancel upload</span>
                    </button>
                    <button type="button" class="btn btn-danger delete">
                        <i class="icon-trash icon-white"></i>
                        <span>Delete</span>
                    </button>
                    <input type="checkbox" class="toggle">
                    <!-- The loading indicator is shown during file processing -->
                    <span class="fileupload-loading"></span>
                </div>
                <!-- The global progress information -->
                <div class="col-lg-5 fileupload-progress fade">
                    <!-- The global progress bar -->
                    <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                        <div class="bar" style="width: 0%;"></div>
                    </div>
                    <!-- The extended global progress information -->
                    <div class="progress-extended">&nbsp;</div>
                </div>
            </div>            
            <hr />
            <!-- The table listing the files available for upload/download -->
            <table role="presentation" class="table table-striped">
                <tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody>
            </table>
        </form>

        <!-- The template to display files available for upload -->
        <script id="template-upload" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-upload fade">
                <td>
                    <span class="preview"></span>
                </td>
                <td>
                    <p class="name">{%=file.name%}</p>
                    {% if (file.error) { %}
                        <div><span class="label label-important">Error</span> {%=file.error%}</div>
                    {% } %}
                </td>
                <td>
                    <p class="size">{%=o.formatFileSize(file.size)%}</p>
                    {% if (!o.files.error) { %}
                        <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
                    {% } %}
                </td>
                <td>
                    {% if (!o.files.error && !i && !o.options.autoUpload) { %}
                        <button class="btn btn-primary start">
                            <i class="icon-upload icon-white"></i>
                            <span>Start</span>
                        </button>
                    {% } %}
                    {% if (!i) { %}
                        <button class="btn btn-warning cancel">
                            <i class="icon-ban-circle icon-white"></i>
                            <span>Cancel</span>
                        </button>
                    {% } %}
                </td>
            </tr>
        {% } %}
        </script>
        <!-- The template to display files available for download -->
        <script id="template-download" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-download fade">
                <td>
                    <span class="preview">
                        {% if (file.thumbnail_url) { %}
                            <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
                        {% } %}
                    </span>
                </td>
                <td>
                    <p class="name">
                        <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
                    </p>
                    {% if (file.error) { %}
                        <div><span class="label label-important">Error</span> {%=file.error%}</div>
                    {% } %}
                </td>
                <td>
                    <span class="size">{%=o.formatFileSize(file.size)%}</span>
                </td>
                <td>
                    <button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                        <i class="icon-trash icon-white"></i>
                        <span>Delete</span>
                    </button>
                    <input type="checkbox" name="delete" value="1" class="toggle">
                </td>
            </tr>
        {% } %}
        </script>
    </div>
    <input id="ServerDocumentId" type="hidden" value="@ViewData["DocumentId"]" />
    <script src="~/Scripts/jquery-2.1.0.min.js"></script>
    <script src="~/Scripts/jquery-ui-1.10.4.min.js"></script>

    <!-- We use Backloads. bundeling feature to register only those client side javascript and style files of the jQuery File Upload Plugin that are needed  -->
    <script src="~/Scripts/FileUpload/jqueryui/jquery.ui.widget.js"></script>
    <script src="~/Scripts/FileUpload/tmpl.debug.js"></script>
    <script src="~/Scripts/FileUpload/load-image.debug.js"></script>
    <script src="~/Scripts/FileUpload/canvas-to-blob.debug.js"></script>
    <script src="~/Scripts/FileUpload/bootstrap/bootstrap.debug.js"></script>
    <script src="~/Scripts/FileUpload/bootstrap/bootstrap-image-gallery.debug.js"></script>
    <script src="~/Scripts/FileUpload/jquery.iframe-transport.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload-process.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload-image.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload-audio.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload-video.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload-validate.js"></script>
    <script src="~/Scripts/FileUpload/jquery.fileupload-ui.js"></script>

    <!-- Initialize the jQuery File Upload Plugin -->
    <script src="~/Scripts/FileUpload/backload.demo.js"></script>
}    
